package com.framework.plugin;

import java.util.Properties;

import com.framework.entity.DatacenterFormMap;
import com.framework.entity.view.UsersourceViewFormMap;
import com.framework.util.Common;
import com.framework.util.PasswordHelper;

public class MapToProperties {

	/*
	 * lpl
	 * map2properties
	 * 将map转换为properties
	 */
	public static Properties map2properties(UsersourceViewFormMap usersourceViewFormMap) {
		if (usersourceViewFormMap!=null) {
			Properties properties=new Properties();
			String username=(String) usersourceViewFormMap.get("db_username");
			String password=(String) usersourceViewFormMap.get("db_password");
			if (!Common.isNotEmpty(usersourceViewFormMap.get("db_position").toString())) {
				return null;
			}
			String url="jdbc:mysql://"+(String) usersourceViewFormMap.get("db_position")+"/"+(String) usersourceViewFormMap.get("db_name");
			properties.put("jdbc.url", url);
			properties.put("jdbc.username", username);
			properties.put("jdbc.password", password);
			return properties;
		}
		
		return null;
	}
	
	/*
	 * lpl
	 * map2properties
	 * 将map转换为properties
	 */
	public static Properties map2properties(DatacenterFormMap datacenterFormMap) {
		if (datacenterFormMap!=null) {
			Properties properties=new Properties();
			String username=(String) datacenterFormMap.get("db_username");
			String password=(String) datacenterFormMap.get("db_password");
			String url="jdbc:mysql://"+(String) datacenterFormMap.get("db_position")+"/"+(String) datacenterFormMap.get("db_name");
			properties.put("jdbc.url", url);
			properties.put("jdbc.username", username);
			properties.put("jdbc.password", password);
			return properties;
		}
		
		return null;
	}
	
	
//	/*
//	 * lpl
//	 * map2properties
//	 * 将map转换为properties
//	 */
//	public static Properties map2properties(ClientsourceViewFormMap clientsourceViewFormMap) {
//		if (clientsourceViewFormMap!=null) {
//			Properties properties=new Properties();
//			String username=(String) clientsourceViewFormMap.get("db_username");
//			String password=(String) clientsourceViewFormMap.get("db_password");
//			String url="jdbc:mysql://"+(String) clientsourceViewFormMap.get("db_position")+"/"+(String) clientsourceViewFormMap.get("db_name");
//			properties.put("jdbc.url", url);
//			properties.put("jdbc.username", username);
//			properties.put("jdbc.password", password);
//			return properties;
//		}
//		
//		return null;
//	}
}
